﻿<%@ Page Title="SD卡数据导入" Buffer="false" Language="C#" MasterPageFile="~/Web/Main.Master" AutoEventWireup="true" CodeBehind="ImportTextData.aspx.cs" Inherits="BOMS.WebUI.Web.WebTool.ImportTextData" %>
<%@ Register Assembly="BOMS.Utility" Namespace="BOMS.Utility.CustomControl" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<link href="swfUpload/css/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="swfUpload/swfupload/swfupload.js"></script>
<script type="text/javascript" src="swfUpload/js/swfupload.queue.js"></script>
<script type="text/javascript" src="swfUpload/js/fileprogress.js"></script>
<script type="text/javascript" src="swfUpload/js/handlers.js"></script>
<script type="text/javascript" src="../../js/jquery-1.4.1.js"></script>
<script type="text/javascript">
    var swfu;
    function PageSWFUpload() {
        var settings = {
            flash_url: "swfUpload/swfupload/swfupload.swf",
            upload_url: "uploadFileHandler.ashx?EquipMac=" + document.getElementById("ctl00_ContentPlaceHolder1_tbxMac").value,
            post_params: {
                "ASPSESSID": "<%=Session.SessionID %>",
                "USERNAME": "<%=UserName%>"
            },
            file_size_limit: "100 MB",
            file_types: "*.txt",    //这是全部文件都可以上传，如果要限制只有某些文件上传，则可以这么写 file_types : "*.jpg;*.gif;*.png",
            file_types_description: "Text Files",
            file_upload_limit: 100,
            file_queue_limit: 0,
            custom_settings: {
                progressTarget: "fsUploadProgress",
                cancelButtonId: "btnCancel"
            },
            debug: false,


            // Button settings

            //这儿是swfupload v2新增加的功能，由于flash player 10的安全性的提高所以增加了此功能。

            //在SWFUpload v2中，不能再使用html的button来触发SWFUpload，必须使用定制的Button，这其中比较要注意的是，button不能再用css控制，需要用图片来显示 


            button_image_url: "swfUpload/images/XPButtonNoText_160x22.png",
            button_placeholder_id: "spanButtonPlaceholder",
            button_width: 160,
            button_height: 22,
            button_text: '<span class="button">&nbsp; &nbsp;选择文件 &nbsp;  &nbsp;<span class="buttonSmall">(2 MB Max)</span></span>',
            button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt;} .buttonSmall { font-size: 10pt; }',
            button_text_top_padding: 1,
            button_text_left_padding: 5,

            // The event handler functions are defined in handlers.js
            file_queued_handler: fileQueued,
            file_queue_error_handler: fileQueueError,
            file_dialog_complete_handler: fileDialogComplete,
            upload_start_handler: uploadStart,
            upload_progress_handler: uploadProgress,
            upload_error_handler: uploadError,
            upload_success_handler: uploadSuccess,
            upload_complete_handler: uploadComplete,
            queue_complete_handler: queueComplete    // Queue plugin event
        };
        swfu = new SWFUpload(settings);
    };

    $(document).ready(
        function() {            
            InitCheckMacValid(); //给tbxMac绑定事件，检查格式是否符合要求,符合则允许上传文件
        });

    function InitCheckMacValid() {
        $("#ctl00_ContentPlaceHolder1_tbxMac").blur(
            function () {
                //alert(1234);
                var mac = $(this).val();
                var reg = /^[0-9,A-F]{2}\-[0-9,A-F]{2}\-[0-9,A-F]{2}\-[0-9,A-F]{2}\-[0-9,A-F]{2}\-[0-9,A-F]{2}$/i;
                if (reg.test(mac)) {
                   // debugger;
                    $("#divUpload").css("display", "");
                    //给上传控件，指定handler路径和参数等
                    PageSWFUpload();
                } else {
                    $("#divUpload").css("display", "none");
                }
            })
    }
    function ConfirmData() {
        return confirm("注意，应确保该文件是正确格式的SD卡数据文件，您确认要将该文件导入数据库么？");
    }

</script>
<style type="text/css">
    #tablFiles {border-collapse:collapse;border-bottom:1px solid #3795d2;border-right:1px solid #3795d2;}
    #tblFiles td{ font-weight:normal;border-bottom:1px solid #3795d2;border-right:1px solid #3795d2;}    
    #ctl00_ContentPlaceHolder1_Pager1 a{display:inline;font-weight:normal;background-image:none;}
    .inputcss{border:1px solid #ccc;padding:0;margin:0;height:20px;vertical-align:middle;line-height:20px;_line-height:21px;}
    .usertablerow2 td{vertical-align:middle;}
    .usertablerow2 input{padding:0 3px;margin:5px 0;height:25px;line-height:20px;_line-height:22px;}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center" border="0">
    <tr>
        <th>上传现场主机SD卡中采集到的txt数据包到服务器</th>
    </tr>
    <tr class="usertablerow4">
        <td>
            <table width="96%" border="0" cellspacing="0" cellpadding="0" align="center" style="margin:10px 0;">
                <tr>
                    <td>MAC地址：<asp:TextBox runat="server" ID="tbxMac" CssClass="inputcss"></asp:TextBox>
                    <img alt="" style="vertical-align:middle;" src="swfUpload/Images/page_white_add.png" onclick="alert('请输入MAC地址后上传！');"/>
                    <span style="font-weight:lighter;margin-left:10px;">（提示：输入mac地址确认你导入的数据属于哪台现场主机，格式：<font color="red">00-BA-DB-AD-01-02</font>）</span></td>
                </tr>
            </table>
            <div id="divUpload" style="display:none;margin:20px;">
                <div id="BtnUpload">
                    <span id="spanButtonPlaceholder"></span>
                    <input id="btnCancel" type="button" value="取消全部上传" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 5px; font-size: 8pt; height: 22px;" />
                </div>
                <div class="fieldset flash" id="fsUploadProgress"><span class="legend">上传队列：</span></div>
                <div id="divStatus">0 个文件已经上传</div>
            </div>
        </td>
    </tr>
</table>
<table class="usertableborder" cellspacing="1" cellpadding="3" width="96%" align="center" border="0">
    <tr>
        <th colspan="7">导入数据库</th>
    </tr>
    <tr>
        <td class="usertablerow3">文件名</td>
        <td class="usertablerow3">大小</td>
        <td class="usertablerow3">备注</td>
        <td class="usertablerow3">所属基站/主机</td>
        <td class="usertablerow3">Mac地址</td>
        <td class="usertablerow3">状态</td>
        <td class="usertablerow3">操作</td>
    </tr>
    <asp:Repeater runat="server" ID="Repeater1">
    <ItemTemplate>
    <tr class="usertablerow2">
        <td align="center"><%#Eval("FileName")%></td>
        <td align="center"><%#Eval("Size")%></td>
        <td align="center"><%#Eval("Memo")%></td>
        <td align="center"><%#Eval("HostName")%></td>
        <td align="center"><%#Eval("EquipMac")%></td>
        <td align="center"><asp:Literal runat="Server" ID="ltrStatus" Text=''></asp:Literal></td>
        <td align="center"><asp:Button runat="server" ID="btnDel" Text="删除" OnClick="btnDel_Click"/>&nbsp;<asp:Button runat="server" ID="btnImport" Text="导入" OnClick="btn_Click"/><asp:HiddenField runat="server" ID="hdfID" value='<%#Eval("ID")%>' /></td>
    </tr> 
    </ItemTemplate>    
    </asp:Repeater>
    <cc1:AspNetPager ID="Pager1" runat="server" OnPageChanged="Pager1_PageChanged" PageSize="15" style="display:block;width:96%;margin:0 auto;"></cc1:AspNetPager>
</table>
</asp:Content>